<?php
class Form_Fooditems extends Zend_Form
{   
	private $i=0;
	private $_identityColumn='cat_id';
	private $_valueColumn= 'cat_name';
	public function init()
	{	
		require_once('models/categories.php');
		$sel = new Model_Categories();
		$data = $sel->fetchEntries();
		$this->setMethod('Post');
		$select = $this->createElement('select','cat_id_item', array(
															'label'=>'Select Category',
												));
		foreach($data as $r){
			
		$options[$r[$this->_identityColumn]] = $r[$this->_valueColumn];	
			
		}
		//$opt = rsort($options);
		$select->setMultiOptions($options);
		$dish = $this->createElement('text','item_name',array(
														'label'=>'Enter dish name'));
		$dish->addValidator('stringLength',false,array(2,20))
			 ->setRequired(true)
			 ->addFilter('StringToUpper')
			 ->addValidator('alpha');
		$uom = $this->createElement('select','uom',array(
													'label'=>'Select UOM'));
		$uom_array = array('Plate'=>'Plate',
							'Pcs'=>'Pcs',
							'Cone'=>'Cone',
							'Bowl'=>'Bowl',
							'Gms'=>'Gms',
							'Kg'=>'Kg');
		$uom->setMultiOptions($uom_array);	
		$uom->setRequired(true);
		    
		$qty = $this->createElement('text','qty',array(
												   'label'=>'Enter the Qty.'));
		$qty->addValidator('stringLength',false,array(1,4))
			->setRequired(true)
			->addValidator('int'); 
		$price = $this->createElement('text','price',array(
												 'label'=>'Enter the Price'));
		$price->addValidator('stringLength',false,array(1,4))
			  ->setRequired(true)
			  ->addValidator('int');	
		
		$submit = $this->createElement('submit','Save');
		$this->addElement($select);
		$this->addElement($dish);
		$this->addElement($uom);
		$this->addElement($qty);
		$this->addElement($price);
		$this->addElement($submit);
		
	}
}
?>